package com.xc.hotelmgr.datahandlermt.controller;


import com.alibaba.fastjson.JSONObject;
import com.xc.hotelmgr.datahandlermt.service.mt.CallBackService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/*
 *变更通知
 *
 */
@Slf4j
@RestController
@RequestMapping("/callback")
@RequiredArgsConstructor
public class CallBackController {

    private final CallBackService callBackService;

    /**
     * 接收美团发送的房态变化
     * @param jsonObject
     * @return
     */
    @RequestMapping(value = "/rs", method = RequestMethod.POST)
    public boolean rs(@RequestBody JSONObject jsonObject) {
        try {
            callBackService.rs(jsonObject);
        }catch (Exception e) {
            log.error(e.toString());
            return false;
        }
        return true;
    }

    /**
     * 接收美团价格政策变化信息
     * @param jsonObject
     * @return
     */
    @RequestMapping(value = "/rp", method = RequestMethod.POST)
    public boolean rp(@RequestBody JSONObject jsonObject) {
        try {
            callBackService.rp(jsonObject);
        }catch (Exception e) {
            log.error(e.toString());
            return false;
        }
        return true;
    }

    /**
     * 接受美团酒店变化信息
     * @param jsonObject
     * @return
     */
    @RequestMapping(value = "/poi", method = RequestMethod.POST)
    public boolean poi(@RequestBody JSONObject jsonObject) {
        try {
            callBackService.poi(jsonObject);
        }catch (Exception e) {
            log.info(e.toString());
            return false;
        }
        return true;
    }
}
